package com.gxa.controller.zls;

import com.gxa.common.R;
import com.gxa.pojo.*;
//import com.gxa.service.CustomerTypeService;
import com.gxa.service.zls.XxxTypeService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Controller
@Api(value = "设置",tags = "设置(辅助资料)数据接口API")
@RequestMapping("/Auxiliarydata")
public class AuxiliarydataController {
    @Autowired(required = false)
    private XxxTypeService xxxTypeService;
    /**
     *              tableId
     * 客户类别         1        customer_type
     * 供应商类别       2        supplier_type
     * 商品类别         3        goods_type    (特殊一点
     * 支出类别         4        pay_type
     * 收入类别         5        income_type
     * 计量单位         6        nuit_type
     * 结算方式         7        settlement_type
     */
    //删除
    @RequestMapping(value = "/delXxxType",method = RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tableId",value = "类别对应tableId",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "id",value = "删除对应编号",paramType = "query",dataType = "String",required = true),
    })
    @ResponseBody
    public R delXxxType(@RequestBody Map map){
        R r = xxxTypeService.delXxxType(map);
        return r;
    }

    //修改
    @RequestMapping(value = "/updateXxxType",method = RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tableId",value = "类别对应tableId",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "id",value = "修改对应编号",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "value",value = "修改对应值",paramType = "query",dataType = "String",required = true),
    })
    @ResponseBody
    public R updateXxxType(@RequestBody Map map){
        R r = xxxTypeService.updateXxxType(map);
        return r;
    }

    //修改商品类别
    @RequestMapping(value = "/updateGoodsType",method = RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "goods_type_id",value = "商品类别编号",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "parent_id",value = "父级商品类别",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "goods_type_name",value = "商品类别新名称",paramType = "query",dataType = "String",required = true),
    })
    @ResponseBody
    public R updateGoodsType(@RequestBody Map map){
        R r = xxxTypeService.updateGoodsType(map);
        return r;
    }

    //添加
    @RequestMapping(value = "/addXxxType",method = RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tableId",value = "类别对应tableId",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "value",value = "新增对应值",paramType = "query",dataType = "String",required = true),
    })
    @ResponseBody
    public R addXxxType(@RequestBody Map map){
        R r = xxxTypeService.addXxxType(map);
        return r;
    }

    //添加商品类别
    @RequestMapping(value = "/addGoodsType",method = RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "parent_id",value = "父级商品类别",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "goods_type_name",value = "新增商品类别名称",paramType = "query",dataType = "String",required = true),
    })
    @ResponseBody
    public R addGoodsType(@RequestBody Map map){
        Object goods_type_name = map.get("goods_type_name");
        Object parent_id = map.get("parent_id");
        R r = xxxTypeService.addGoodsType(goods_type_name,parent_id);
        return r;
    }

    //查询
    @RequestMapping(value = "/queryXxxType",method = RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tableId",value = "类别对应tableId",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "value",value = "搜索框值",paramType = "query",dataType = "String",required = false),
    })
    @ResponseBody
    public R queryXxxType(@RequestBody Map map){
        R r = xxxTypeService.queryXxxType(map);
        return r;
    }












//    @Autowired
//    private CustomerTypeService customerTypeService;
//    /**
//     * 添加客户接口
//     * @param customer
//     * @return
//     */
//    @RequestMapping(value = "/addCustomer",method = RequestMethod.POST)
//    @ApiOperation(value = "添加客户接口",notes = "添加客户",httpMethod = "get", response = String.class)
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=404,message="找不到页面"),
//            @ApiResponse(code=500,message="后台服务错误")
//    })
//    @ResponseBody
//    public R addAccount(@RequestBody @ApiParam(name = "customer",value = "客户") Customer_Type customer){
//        R r=new R();
//        if (customer!=null){
//            int result=customerTypeService.addCustomerType(customer);
//            System.out.println(result);
//            System.out.println(customer.getCustomer_type_id());
//            System.out.println(customer.getCustomer_type_name());
//            r.setCode(200);
//            r.setMsg("success");
//            r.setData(customer);
//        }
//        return r;
//    }

    /**
     * 添加供应商接口
     * @param supplier
     * @return
     */
//    @RequestMapping(value = "/addSupplier",method = RequestMethod.POST)
//    @ApiOperation(value = "添加供应商接口",notes = "添加供应商",httpMethod = "post", response = String.class)
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=404,message="找不到页面"),
//            @ApiResponse(code=500,message="后台服务错误")
//    })
//    @ResponseBody
//    public R addSupplier(@RequestBody @ApiParam(name = "supplier",value = "供应商") Supplier_Type supplier){
//        R r=new R();
//        if (supplier!=null){
//            System.out.println(supplier.getSupplier_Type_Id());
//            System.out.println(supplier.getSupplier_Type_Name());
//            r.setCode(200);
//            r.setMsg("success");
//            r.setData(supplier);
//        }
//        return r;
//    }
//
//    /**
//     * 添加商品类别接口
//     * @param goods
//     * @return
//     */
//    @RequestMapping(value = "/addGoods",method = RequestMethod.POST)
//    @ApiOperation(value = "添加商品接口",notes = "添加商品商",httpMethod = "post", response = String.class)
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=404,message="找不到页面"),
//            @ApiResponse(code=500,message="后台服务错误")
//    })
//    @ResponseBody
//    public R addGoods(@RequestBody @ApiParam(name = "goods",value = "商品") Goods_Type goods){
//        R r=new R();
//        if (goods!=null){
//            System.out.println(goods.getGoods_Type_Id());
//            System.out.println(goods.getGoods_Type_Name());
//            r.setCode(200);
//            r.setMsg("success");
//            r.setData(goods);
//        }
//        return r;
//    }
//
//    /**
//     * 添加支付方式接口
//     * @param pay
//     * @return
//     */
//    @RequestMapping(value = "/addPay",method = RequestMethod.POST)
//    @ApiOperation(value = "添加支付类别接口",notes = "添加支付类别",httpMethod = "post", response = String.class)
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=404,message="找不到页面"),
//            @ApiResponse(code=500,message="后台服务错误")
//    })
//    @ResponseBody
//    public R addPay(@RequestBody @ApiParam(name = "pay",value = "支付") Pay_Type pay){
//        R r=new R();
//        if (pay!=null){
//            System.out.println(pay.getPay_Type_Id());
//            System.out.println(pay.getPay_Type_Name());
//            r.setCode(200);
//            r.setMsg("success");
//            r.setData(pay);
//        }
//        return r;
//    }
//
//    /**
//     * 添加收入方式类别接口
//     * @param Income
//     * @return
//     */
//    @RequestMapping(value = "/addIncome",method = RequestMethod.POST)
//    @ApiOperation(value = "添加收入类别接口",notes = "添加收入类别",httpMethod = "post", response = String.class)
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=404,message="找不到页面"),
//            @ApiResponse(code=500,message="后台服务错误")
//    })
//    @ResponseBody
//    public R addIncome(@RequestBody @ApiParam(name = "Income",value = "收入") Income_Type Income){
//        R r=new R();
//        if (Income!=null){
//            System.out.println(Income.getIncome_Type_Id());
//            System.out.println(Income.getIncome_Type_Name());
//            r.setCode(200);
//            r.setMsg("success");
//            r.setData(Income);
//        }
//        return r;
//    }
//
//    /**
//     * 添加计量单位接口
//     * @param Nuit
//     * @return
//     */
//    @RequestMapping(value = "/addNuit",method = RequestMethod.POST)
//    @ApiOperation(value = "添加计量单位类别接口",notes = "添加计量单位类别",httpMethod = "post", response = String.class)
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=404,message="找不到页面"),
//            @ApiResponse(code=500,message="后台服务错误")
//    })
//    @ResponseBody
//    public R addNuit(@RequestBody @ApiParam(name = "nuit",value = "计量单位") Nuit_Type Nuit){
//        R r=new R();
//        if (Nuit!=null){
//            System.out.println(Nuit.getNuit_Type_Id());
//            System.out.println(Nuit.getNuit_Type_Name());
//            r.setCode(200);
//            r.setMsg("success");
//            r.setData(Nuit);
//        }
//        return r;
//    }
//
//    /**
//     * 添加结算方式接口
//     * @param Settlement
//     * @return
//     */
//    @RequestMapping(value = "/addSettlement",method = RequestMethod.POST)
//    @ApiOperation(value = "添加结算方式类别接口",notes = "添加计量单位类别",httpMethod = "post", response = String.class)
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=404,message="找不到页面"),
//            @ApiResponse(code=500,message="后台服务错误")
//    })
//    @ResponseBody
//    public R addSettlement(@RequestBody @ApiParam(name = "Settlement",value = "结算方式") Settlement_Type Settlement){
//        R r=new R();
//        if (Settlement!=null){
//            System.out.println(Settlement.getSettlement_Type_Id());
//            System.out.println(Settlement.getSettlement_Type_Name());
//            r.setCode(200);
//            r.setMsg("success");
//            r.setData(Settlement);
//        }
//        return r;
//    }
//
//    /**
//     * 查询客户类别接口
//     * @return
//     */
//    @RequestMapping(value = "/queryCustomer",method = RequestMethod.GET)
//    @ApiOperation(value = "查询客户类别接口",notes = "查询客户类别",httpMethod = "get", response = String.class)
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=404,message="找不到页面"),
//            @ApiResponse(code=500,message="后台服务错误")
//    })
//    @ResponseBody
//    public R queryCustomerType(){
////        List list=new ArrayList();
////        Customer_Type customer_type=new Customer_Type();
////        customer_type.setCustomer_type_id(1);
////        customer_type.setCustomer_type_name("大客户");
////        Customer_Type customer_type2=new Customer_Type();
////        customer_type2.setCustomer_type_id(2);
////        customer_type2.setCustomer_type_name("小客户");
////        list.add(customer_type);
////        list.add(customer_type2);
//        R r=new R();
//            r.setCode(200);
//            r.setMsg("success");
////            r.setData(list);
//        return r;
//    }
//
//    /**
//     * 查询供应商接口
//     * @return
//     */
//    @RequestMapping(value = "/querySupplierType",method = RequestMethod.GET)
//    @ApiOperation(value = "查询供应商",notes = "查询供应商",httpMethod = "get", response = String.class)
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=404,message="找不到页面"),
//            @ApiResponse(code=500,message="后台服务错误")
//    })
//    @ResponseBody
//    public R querySupplierType(){
//        List list=new ArrayList();
//        Supplier_Type supplier=new Supplier_Type();
//       supplier.setSupplier_Type_Id(1);
//       supplier.setSupplier_Type_Name("供应商一");
//        Supplier_Type supplier2=new Supplier_Type();
//        supplier2.setSupplier_Type_Id(1);
//        supplier2.setSupplier_Type_Name("供应商二");
//        list.add(supplier);
//        list.add(supplier2);
//        R r=new R();
//        r.setCode(200);
//        r.setMsg("success");
//        r.setData(list);
//        return r;
//    }
//
//    /**
//     * 查询商品接口
//     * @return
//     */
//    @RequestMapping(value = "/queryGoodsType",method = RequestMethod.GET)
//    @ApiOperation(value = "查询商品接口",notes = "查询商品",httpMethod = "get", response = String.class)
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=404,message="找不到页面"),
//            @ApiResponse(code=500,message="后台服务错误")
//    })
//    @ResponseBody
//    public R queryGoodsType(){
//        List list=new ArrayList();
//        Goods_Type goods=new Goods_Type();
//        goods.setGoods_Type_Id(1);
//        goods.setGoods_Type_Name("生活用品类");
//        Goods_Type goods2=new Goods_Type();
//        goods2.setGoods_Type_Id(2);
//        goods2.setGoods_Type_Name("电器类");
//        list.add(goods);
//        list.add(goods2);
//        R r=new R();
//        r.setCode(200);
//        r.setMsg("success");
//        r.setData(list);
//        return r;
//    }
//
//    /**
//     * 查询支付类别接口
//     * @return
//     */
//    @RequestMapping(value = "/queryPayType",method = RequestMethod.GET)
//    @ApiOperation(value = "查询支付类别接口",notes = "查询支付类别",httpMethod = "get", response = String.class)
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=404,message="找不到页面"),
//            @ApiResponse(code=500,message="后台服务错误")
//    })
//    @ResponseBody
//    public R queryPayType(){
//        List list=new ArrayList();
//        Pay_Type pay=new Pay_Type();
//        pay.setPay_Type_Id(1);
//        pay.setPay_Type_Name("现金");
//        Pay_Type pay2=new Pay_Type();
//        pay2.setPay_Type_Id(2);
//        pay2.setPay_Type_Name("微信");
//        list.add(pay);
//        list.add(pay2);
//        R r=new R();
//        r.setCode(200);
//        r.setMsg("success");
//        r.setData(list);
//        return r;
//    }
//
//    /**
//     * 查询收入类别接口
//     * @return
//     */
//    @RequestMapping(value = "/queryincomeType",method = RequestMethod.GET)
//    @ApiOperation(value = "查询收入类别接口",notes = "收入类别",httpMethod = "get", response = String.class)
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=404,message="找不到页面"),
//            @ApiResponse(code=500,message="后台服务错误")
//    })
//    @ResponseBody
//    public R queryIncomeType(){
//        List list=new ArrayList();
//        Income_Type Income=new Income_Type();
//        Income.setIncome_Type_Id(1);
//        Income.setIncome_Type_Name("水电费");
//        Income_Type Income2=new Income_Type();
//        Income2.setIncome_Type_Id(2);
//        Income2.setIncome_Type_Name("仓库管理费");
//        list.add(Income);
//        list.add(Income2);
//        R r=new R();
//        r.setCode(200);
//        r.setMsg("success");
//        r.setData(list);
//        return r;
//    }
//
//    /**
//     * 查询计量单位类别
//     * @return
//     */
//    @RequestMapping(value = "/queryNuitType",method = RequestMethod.GET)
//    @ApiOperation(value = "查询计量单位类别接口",notes = "计量单位",httpMethod = "get", response = String.class)
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=404,message="找不到页面"),
//            @ApiResponse(code=500,message="后台服务错误")
//    })
//    @ResponseBody
//    public R queryNuitType(){
//        List list=new ArrayList();
//        Nuit_Type nuit=new Nuit_Type();
//        nuit.setNuit_Type_Id(1);
//        nuit.setNuit_Type_Name("吨");
//        Nuit_Type nuit2=new Nuit_Type();
//        nuit2.setNuit_Type_Id(2);
//        nuit2.setNuit_Type_Name("个");
//        list.add(nuit);
//        list.add(nuit2);
//        R r=new R();
//        r.setCode(200);
//        r.setMsg("success");
//        r.setData(list);
//        return r;
//    }
//
//    /**
//     * 查询结算方式类别接口
//     * @return
//     */
//    @RequestMapping(value = "/querySettlementType",method = RequestMethod.GET)
//    @ApiOperation(value = "查询结算方式类别接口",notes = "计量单位",httpMethod = "get", response = String.class)
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=404,message="找不到页面"),
//            @ApiResponse(code=500,message="后台服务错误")
//    })
//    @ResponseBody
//    public R querySettlementType(){
//        List list=new ArrayList();
//        Settlement_Type settlement=new Settlement_Type();
//        settlement.setSettlement_Type_Id(1);
//        settlement.setSettlement_Type_Name("微信");
//        Settlement_Type settlement2=new Settlement_Type();
//        settlement2.setSettlement_Type_Id(1);
//        settlement2.setSettlement_Type_Name("支付宝");
//        list.add(settlement);
//        list.add(settlement2);
//        R r=new R();
//        r.setCode(200);
//        r.setMsg("success");
//        r.setData(list);
//        return r;
//    }

}
